import pandas as pd
import os
from scipy import misc
import numpy as np
base_dir = "/data/station/FATP_FB"
bdirs = sorted(os.listdir(base_dir))
totals = 150528 # 图片总像素数w*h*channel
columns = []
for i in range(totals):
    columns.append(f'pixel{i+1}')
columns.append('label')
df = pd.DataFrame(columns=columns)
for i,tdir in enumerate(bdirs):
    dpath = os.path.join(base_dir,tdir)
    for j in os.listdir(dpath)[-10:-6]:
        ipath = os.path.join(dpath,j)
        img:np.ndarray = misc.imread(ipath)
        img = misc.imresize(img, (224, 224))
        data=img.flatten()
        data = np.append(data,i) # 数据+标签
        k = pd.DataFrame([data], columns=columns)
        df = df.append(k, ignore_index=True)# df添加一行
        del k
df.to_csv("/data/soft/redldw/eval.csv",index=False)
